<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="erzu/css/style.css" rel="stylesheet" type="text/css"/>

    <script src="../vue.min.js"></script>
    <script src="../axios.min.js"></script>

    <script type="text/javascript" src="erzu/js/jquery.js"></script>
    <script language="javascript">
        $(function () {
            //导航切换
            $(".imglist li").click(function () {
                $(".imglist li.selected").removeClass("selected")
                $(this).addClass("selected");
            })
        })
    </script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".click").click(function () {
                $(".tip").fadeIn(200);
            });

            $(".tiptop a").click(function () {
                $(".tip").fadeOut(200);
            });

            $(".sure").click(function () {
                $(".tip").fadeOut(100);
            });

            $(".cancel").click(function () {
                $(".tip").fadeOut(100);
            });

        });
    </script>
</head>


<body>


<div id="app">
    <!--<br>
        <a href="log.html?role_id=3" class="ibtn">查看BI工作记录</a>
        <a href="log.html?role_id=2" class="ibtn">查看DBI工作记录</a>

    <br>
    <br>-->


    <div class="leftinfo">
        <div class="listtitle">任务列表</div>
        <input type="button" class="ibtn" value="新建任务" @click="tiao()"/>
<!--        <input type="button" class="ibtn" value="核心库迁移" @click="tiao1()"/>-->
        <table class="imgtable">
            <tr>
                <td>任务编号</td>
                <td>提交人</td>
                <td>提交时间</td>
                <td>源数据库名</td>
                <td>源数据表名</td>
                <td>目标数据库名</td>
                <td>目标数据表名</td>
                <td>审核状态</td>
                <td>操作</td>
            </tr>
            <tr v-model="task" v-for="item in taskList">
                <td>{{item.taskNumber}}</td>
                <td>{{item.submitName}}</td>
                <td>{{item.cdate}}</td>
                <td>{{item.sourceDatabaseName}}</td>
                <td>{{item.sourceTableName}}</td>
                <td>{{item.targetDatabaseName}}</td>
                <td>{{item.targetTableName}}</td>
                <td v-if="item.status=='2'">未审核</td>
                <td v-if="item.status=='1'">审核通过</td>
                <td v-if="item.status=='0'">审核不通过</td>
                <td v-if="item.status=='3'">任务取消</td>
                <td v-if="item.status=='4'">任务完成</td>
                <td v-if="item.status=='5'">正在迁移</td>
                <td>

                    <button v-if="item.status!='1'" disabled>开始迁移</button>

                    <button v-else @click="dataMigration(item.id,item.coreFields)">开始迁移</button>
                    |
                    <button @click="deleteTask(item.id)">删除</button>
                </td>

                <!-- <td><input type="button" class="ibtn" value="审核通过" @click="audit(item.task_id,'1')"/>
                    <input type="button"  class="ibtn" value="审核未通过" @click="audit(item.task_id,'2')"/>
                </td> -->
            </tr>
        </table>
    </div>
</div>

<!-- <div class="pagin">
    <div class="message">共<i class="blue">1256</i>条记录，当前显示第&nbsp;<i class="blue">2&nbsp;</i>页</div>
    <ul class="paginList">
        <li class="paginItem"><a href="javascript:;"><span class="pagepre"></span></a></li>
        <li class="paginItem"><a href="javascript:;">1</a></li>
        <li class="paginItem current"><a href="javascript:;">2</a></li>
        <li class="paginItem"><a href="javascript:;">3</a></li>
        <li class="paginItem"><a href="javascript:;">4</a></li>
        <li class="paginItem"><a href="javascript:;">5</a></li>
        <li class="paginItem more"><a href="javascript:;">...</a></li>
        <li class="paginItem"><a href="javascript:;">10</a></li>
        <li class="paginItem"><a href="javascript:;"><span class="pagenxt"></span></a></li>
    </ul>
</div> -->


<script type="text/javascript">
    $('.imgtable tbody tr:odd').addClass('odd');
</script>
</body>
<script>
    new Vue({
        el: "#app",
        data: {
            task: "0",
            taskList: []
        },
        created: function () {
            this.gettaskList();
        },
        methods: {
            gettaskList: function () {
                var Authorization = localStorage.getItem('Authorization');
                var username = localStorage.getItem('username');
                axios.get("http://localhost:9005/dba/dbaController/findTask?username="+username, {headers: {'Authorization': Authorization}}).then(response => {
                    this.taskList = response.data.data;
                }).catch(function (error) {
                  if (5102 == error.response.status) {

                      alert("无权限");
                      location.href="wuquan.html";
                      
                  }
              })
                // axios.get("http://localhost:9005/dba/dbaController/getLinkName",{headers:{'Authorization': Authorization}}).then(response => {
                //     console.log(response);
                // })

            },
            dataMigration: function (id,field) {
                 var Authorization = localStorage.getItem('Authorization');
                 if(field==null){
                     axios.get("http://localhost:9005/dba/dbaController/dataMigration/" + id, {headers: {'Authorization': Authorization}}).then(response => {
                         alert('开始迁移');
                         location.reload();
                     })
                 }
                 else{
                    axios.get("http://localhost:9005/dba/dbaController/dataMigrationCore/" + id, {headers: {'Authorization': Authorization}}).then(response => {
                        alert('开始迁移');
                        location.reload();
                    })
                }
                
                
            },
            deleteTask: function (id) {
                var Authorization = localStorage.getItem('Authorization');

                axios.get("http://localhost:9005/dba/dbaController/deleteTaskById/" + id, {headers: {'Authorization': Authorization}}).then(response => {
                    alert(response.data.message);
                    location.reload();
                })
            },
            tiao: function () {

                location.href = "renwu.html";
            },
            tiao1: function () {

                location.href = "renwu1.html";
            }

        }
    })
</script>
</html>
